/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.etop.odbs.dao;

import com.etop.odbs.beans.User;

/**
 *
 * @author cjh
 */
public class UserDao extends BaseDao {

    /**
     * 通过key获取相应的用户
     *
     * @param key
     * @return
     */
    public User load(String key) {
        String col = key.contains("@") ? "email" : "phone";
        String hql = "from User where " + col + " = :key";
        return (User) this.getSession().createQuery(hql).setParameter("key", key).uniqueResult();
    }
}
